import java.util.Scanner;
import java.util.Stack;

/**
 * @author yixian
 *
 */
public class Main {

	private static Scanner scanner;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		do{
			System.out.print("Calc:");
			String line = in.nextLine();
			if (line.toString().charAt(0)=='q') {
				break;
			}
			try{
				Expression a = new Expression(line);
				System.out.println(a.ans());
			}
			catch(Exception e){
				System.out.println("There's something wrong.");
			}
		}while (true);

		return;
	}

}

class Expression {
	Stack<Integer> number=new Stack<Integer>();
	Stack<Character> operator=new Stack<Character>();
	boolean num_tag;
	Integer X,res;
	public Expression(String expression) {
		// System.out.println(expression);
		init();
		char[] expr=expression.toCharArray();
		int i=0;
		while (expr[i]==' ') {
			i++;
		}
		if (expr[i]=='+'||expr[i]=='-') {
			number.push(0);
		}
		// System.out.println(expr);
		for (int j = i; j < expr.length; j++) {
			char c = expr[j];
			if(c==' ')continue;
			// System.out.println(c);
			int lv = level(c);
			if(lv>0){
				if (num_tag){
					number.push(X);
					num_tag=false;
					X=0;
				}
				while(!operator.empty() && level(operator.peek())>=lv){
					calc();
				}
				operator.push(c);
				// System.out.println(c);
			}
			else if(lv==0){
				if(!num_tag) num_tag=true;
				X=X*10+c-'0';
				// System.out.println(X);
			}
			else if(lv==-1){
				if(c=='('){
					if (num_tag){
						number.push(X);
						num_tag=false;
						X=0;
					}
					operator.push('(');
				}
				else{
					if (num_tag){
						number.push(X);
						X=0;
						num_tag=false;
					}
					while(operator.peek()!='(') calc();
					operator.pop();
				}
			}
			else return;
		}
		if (num_tag){
					number.push(X);
					num_tag=false;
					X=0;
				}
		while(number.size()>1)calc();
		res=number.peek();
	}

	int level(char ch){
		if (ch=='+'||ch=='-')  return 1;
		else if (ch=='*'||ch=='/'||ch=='%') return 2;
		else if (ch=='('||ch==')')  return -1;
		else if (ch=='#') return -2;
		else if(ch>='0'&&ch<='9') return 0;
		else return -3;

	}

	void init(){
		num_tag=false;
		X=0;
	}

	void calc(){
		// System.out.println("calc once");
		Integer x=number.pop();
		Integer y=number.pop();
		Character op=operator.pop();
		if(op=='+')y=y+x;
		else if(op=='-')y=y-x;
		else if(op=='*')y=y*x;
		else if(op=='/')y=y/x;
		else if(op=='%')y=y%x;
		number.push(y);
		// System.out.println(y);
		return;
	}

	public Integer ans(){
		return res;
	}
}

